@import "@/assets/styles/_theme.scss";

@mixin themeify {
  @each $theme-name, $theme-map in $themes {
    // !global 把局部变量强升为全局变量
    $theme-map: $theme-map !global;
    // 这步是判断html的data-theme的属性值 #{}是sass的插值表达式
    // & sass嵌套里的父容器标识 @content是混合器插槽，像vue的slot
    [data-theme="#{$theme-name}"] & {
      @content;
    }
  }
}

// 声明一个根据key获取颜色的function
@function themed($key) {
  @return map-get($theme-map, $key);
}

@mixin background_color($color) {
  @include themeify {
    background-color: themed($color);
  }
}

@mixin font_color($color) {
  @include themeify {
    color: themed($color);
  }
}

@mixin border_color($color) {
  @include themeify {
    border-color: themed($color);
  }
}

@mixin vet_switch_style {
  @include themeify {
    border-color: themed("vet-switch-border-color");
    background-color: themed("vet-switch-background-color");
  }
}
